package androidmodules.screencapture;

import com.androidmodules.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

public class ScreenCaptureTest 
{
	final String TAG = "ScreenCaptureTest";
	Activity mActivity = null;
	LinearLayout mainActivityLo = null;
	public ScreenCaptureTest(Activity activity)
	{
		mActivity = activity;
		mainActivityLo = (LinearLayout)mActivity.findViewById(R.id.mainActivityLo);
	
		getScreenBitmap();
	}
	
	@SuppressLint("NewApi") 
	void getScreenBitmap()
	{
		ImageView imageView = new ImageView(mActivity);
		ScreenCapture screenCapture = new ScreenCapture(mActivity);
		Bitmap bitmap = screenCapture.getScreenBitmap();
		if(bitmap!=null)
		{
			imageView.setBackground(new BitmapDrawable(bitmap));
			mainActivityLo.addView(imageView);
		}else
		{
			Toast.makeText(mActivity, "bitmap is null !!", Toast.LENGTH_LONG).show();
		}
		
	}

}
